<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <title>Radiator Information List</title>
    <script type="text/javascript">
    	var path = "<%=basePath%>";
    </script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<link rel="stylesheet" type="text/css" href="<%=basePath%>beshs/css/content.css" />
	<style type="text/css">
	<![CDATA[
/* 		a.preview_pic{background:#333;  */
/* 					 display:block; width:200px; height:200px; }    */
/*  		#bigimage{position:absolute; display:none; }    */
/*  		#bigimage img{width:400px;  */
/*  					 height:400px;  */
/*  					 padding:5px;  */
/*  					 background:#fff;  */
/*  					 border:1px solid #e3e3e3; } */
	]]>
	</style>
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<!-- 用户访问菜单路径 -->
	<jsp:include page="/resources/usertrace/common-uservisit-reference.jsp" />
  </head>
  <script type="text/javascript">
  function addNewHeatSinker() {
		loadNewModal(path+"beshs/sinkerStandardDictAction!querySinkerDictForManage.do?date="+new Date(),"Add standard radiator information","350px","1050px");
	}
	
	function showSinkerDetail(sinkerDictUID) {
		window.location = path + "beshs/sinkerStandardDictAction!querySinkerdictDetail.do?sinkerDictUID="+sinkerDictUID+"&date="+new Date();
	}
	
	function updateHeatSinker(sinkerDictUID) {
		loadNewModal(path+"beshs/sinkerStandardDictAction!querySinkerDictForManage.do?sinkerDictUID="+sinkerDictUID+"&date="+new Date(),"Modify standard radiator information","350px","1050px");
	}
  	
  	function deleteHeatSinker(sinkerDictUID) {
  		Dialog.confirm("Are you sure to delete this radiator?", function() {
  			$.getJSON(path+"beshs/sinkerStandardDictActionJson!deleteSinkerDictByUID.do?date="+new Date(), {
  				sinkerDictUID: sinkerDictUID
  	  		}, function(data) {
  	  			if(data.success) {
  	  				Dialog.alert("Successful Operation！", function() {
  	  					window.location = path + "beshs/sinkerStandardDictAction!queryStandardSinkerPage.do?date="+new Date();
  	  				});
  	  			} else {
  	  				Dialog.alert("System error, please contact adminitrator！");
  	  			}
  	  		});
  		});
  	}
  	
  	function uploadSinkerDictBatch() {
  		loadNewModal(path+"beshs/sinkerStandardDictAction!initSinkerDictUpload.do?date="+new Date(),"Import standard radiator information","170px","450px");
	}
  	
  	$(function(){
  		$("input[name='query']").click(function(){
  			var dictSerious = $("input[name='dictSerious']").val();
  			var sinkType = $("input[name='sinkType']").val();
  			var brand = $("input[name='brand']").val();
  			window.location = path + "beshs/sinkerStandardDictAction!queryStandardSinkerPage.do?date="+new Date()
  					+"&dictSerious="+dictSerious
  					+"&sinkType="+encodeURIComponent(sinkType)
  					+"&brand="+encodeURIComponent(brand);
  		});
  		
  		$("input[name='add']").click(function(){
  			addNewHeatSinker();
  		});
  		
  		$("input[name='importSinkerDict']").click(function() {
  			uploadSinkerDictBatch();
  		});
  		
  		$("input[name='download']").click(function() {
  			window.location = path + "beshs/sinkerStandardDictAction!downloadExcelTemplate.do?date="+new Date();
  		}) 
  	});
  </script>
  <body>
    <div class="content_all">
	  	<!--查询条件-->
	  	<div class="search">
	    	<form action=""><table cellpadding="0" cellspacing="0">
	    		<tr>
	    			<th>Model Dictionary No.：</th>
			        <td><input name="dictSerious" value="<s:property value='dictSerious' />" type="text" class="s_input" /></td>
	    			<th>Radiator Type：</th>
			        <td><input name="sinkType" value="<s:property value='sinkType' />" type="text" class="s_input" /></td>
			        <th>Radiator Brand ：</th>
	      			<td><input name="brand" value="<s:property value='brand' />" type="text" class="s_input" /></td>	
	      			<td>
	      			    <input name="query" type="button" value="Query" class="s_btn" />
			        	<input name="reset" type="reset" value="Reset" class="s_btn" />
			        	<s:if test="superManager.contains(#session.user.userID) 
								|| loginUserRoleIDList.contains(sysadmin) 
								|| loginUserRoleIDList.contains(sysShareManager)">
							<input name="add" type="button" value="Add" class="s_btn" />
		        			<input name="importSinkerDict" type="button" value="Excel Import" class="s_btn" />
		        			<input name="download" type="button" value="Template DownLoad" class="s_btn" />
						</s:if>
	        	    </td>					
				</tr>
	    	</table></form>
	  	</div>
	  	<!--查询列表-->
	  	<div class="search_table_all">
	  		<!-- 散热器照片预览 -->
	  		<script type="text/javascript">
	  		function uploadSinkerImage(sinkerDictUID) {
				loadNewModal(path + "beshs/sinkerStandardDictAction!initSinkerDictImageUpload.do?sinkerDictUID=" + sinkerDictUID + "&date=" + new Date(), "Upload photos","260px","550px");
			}
				
				function previewSinkerImage(sinkerDictUID) {
					$.getJSON(path+"beshs/sinkerStandardDictActionJson!querySinkerDictPicRelURL.do?date="+ new Date(), {
						sinkerDictUID : sinkerDictUID
					}, function(data) {
						if (data.success) {
							window.open(path + data.msg);
						} else {
							Dialog.alert(data.msg)
						}
					});
				}
			</script>
	    	<table class="search_table" cellspacing="0" cellpadding="0">
	      		<thead>
	        		<tr>
		          		<th style="width:30px;">Serial No.</th>
		          		<th>Model Dictionary No.</th>
						<th>Radiator Type</th>
						<th>Radiator Brand</th>
						<th>Radiator Height</th>
						<th>Radiator Width</th>
						<th>Radiator Length</th>
						<th>Radiator Central Distance</th>
						<th>Power Calculation of Each Fin</th>
			          	<th>Operation</th>
	        		</tr>
	      		</thead>
	      		<tbody>
	      			<s:iterator value="sinkerDictPage.list" var="sinkerDict" status="status">
	      				<tr>
		          			<td><s:property value="#status.index+1" /></td>
		          			<td>
		          				<s:property value="#sinkerDict.dictSerious" />
		          				<s:if test="#sinkerDict.pictureNo!=null && !''.equals(#sinkerDict.pictureNo)">
		          				  <a href="javascript:void(0)" class="preview_pic" onclick="javascript:previewSinkerImage('<s:property value='#sinkerDict.id' />')" >
		          					<img src="<%=basePath%>beshs/images/attachment.gif" alt="photo" />
		          				  </a>
		          				</s:if>
		          				<s:else>
		          				  <a href="javascript:void(0)">
		          					<img src="<%=basePath%>beshs/images/application_get.png" onclick="javascript:uploadSinkerImage('<s:property value='#sinkerDict.id' />')" alt="no photo" />
		          				  </a>
		          				</s:else>
		          			</td>
		          			<td><s:property value="#sinkerDict.sinkType" /></td>
		          			<td><s:property value="#sinkerDict.brand" /></td>
		          			<td><s:property value="#sinkerDict.sinkHeight" /></td>
		          			<td><s:property value="#sinkerDict.sinkWidth" /></td>
		          			<td><s:property value="#sinkerDict.sinkLength" /></td>
		          			<td><s:property value="#sinkerDict.sinkCenDis" /></td>
		          			<td><s:property value="#sinkerDict.calPower" /></td>
		          			<td><a href="javascript:showSinkerDetail('<s:property value='#sinkerDict.id' />')">[Check]</a>
		          				<s:if test="superManager.contains(#session.user.userID) 
										|| loginUserRoleIDList.contains(sysadmin) 
										|| loginUserRoleIDList.contains(sysShareManager)">
									&nbsp;&nbsp;<a href="javascript:updateHeatSinker('<s:property value='#sinkerDict.id' />')">[Modify]</a>
		          					&nbsp;&nbsp;<a href="javascript:deleteHeatSinker('<s:property value='#sinkerDict.id' />')">[Delete]</a>
								</s:if>
		          			</td>
		        		</tr>
	      			</s:iterator>
	      		</tbody>
	    	</table>
	  	</div>
	  	<!--操作按钮&分页-->
	  	<script type="text/javascript">
	  		function pageUp(pageIndex) {
	  			var dictSerious = $("input[name='dictSerious']").val();
	  			var sinkType = $("input[name='sinkType']").val();
	  			var brand = $("input[name='brand']").val();
	  			window.location = path + "beshs/sinkerStandardDictAction!queryStandardSinkerPage.do?pageIndex="+(pageIndex-1)
	  					+"&dictSerious="+dictSerious
	  					+"&sinkType="+encodeURIComponent(sinkType)
	  					+"&brand="+encodeURIComponent(brand);
	  					+"&date="+new Date();
	  		}
	  		
			function pageDown(pageIndex) {
				var dictSerious = $("input[name='dictSerious']").val();
	  			var sinkType = $("input[name='sinkType']").val();
	  			var brand = $("input[name='brand']").val();
				window.location = path + "beshs/sinkerStandardDictAction!queryStandardSinkerPage.do?pageIndex="+(pageIndex+1)
						+"&dictSerious="+dictSerious
	  					+"&sinkType="+encodeURIComponent(sinkType)
	  					+"&brand="+encodeURIComponent(brand);
						+"&date="+new Date();
	  		}
			
			function pageLocate(pageIndex) {
				var dictSerious = $("input[name='dictSerious']").val();
	  			var sinkType = $("input[name='sinkType']").val();
	  			var brand = $("input[name='brand']").val();
				window.location = path + "beshs/sinkerStandardDictAction!queryStandardSinkerPage.do?pageIndex="+pageIndex
						+"&dictSerious="+dictSerious
	  					+"&sinkType="+encodeURIComponent(sinkType)
	  					+"&brand="+encodeURIComponent(brand);
						+"&date="+new Date();
			}
	  	</script>
	  	<div class="search_control">
	    	<div class="right">
	      		<div class="pages">
	      		<!-- 上一页 -->
	      			<s:if test="pageIndex==1">
	      				<a href="javascript:void(0)" class="disabled">Former Page</a>
	      			</s:if>
	      			<s:else>
	      				<a href="javascript:pageUp(<s:property value='pageIndex' />)">Former Page</a>
	      			</s:else>
	      		<!-- 页码 -->
	      			<s:if test="pageSize<=0">
	      			<!-- 若分页页数未初始化或为0，则只显示第一页 -->
	      				<a href="javascript:void(0)" class="current">1</a>
	      			</s:if>
	      			<s:elseif test="pageSize<=9">
	      			<!-- 页数在9页以内全显示 -->
	      				<s:bean name="org.apache.struts2.util.Counter" id="counter">
	      					<s:param name="first" value="1" />
	      					<s:param name="last" value="pageSize" />
	      					<s:iterator value="counter" var="index">
	      						<s:if test="#index==pageIndex">
		      						<a href="javascript:void(0)" class="current"><s:property value="#index" /></a>
		      					</s:if>
		      					<s:else>
		      						<a href="javascript:pageLocate(<s:property value='#index' />)"><s:property value="#index" /></a>
		      					</s:else>
	      					</s:iterator>
	      				</s:bean>
	      			</s:elseif>
	      			<s:else>
	      			<!-- 页数在9页以上则部分显示 -->
	      				<s:if test="pageIndex<7">
	      				<!-- 页码小于7时，先显示前7页 -->
	      					<s:bean name="org.apache.struts2.util.Counter" id="frontCounter">
	      						<s:param name="first" value="1" />
	      						<s:param name="last" value="7" />
	      						<s:iterator value="frontCounter" var="index">
	      							<s:if test="#index==pageIndex">
			      						<a href="javascript:void(0)" class="current"><s:property value="#index" /></a>
			      					</s:if>
			      					<s:else>
			      						<a href="javascript:pageLocate(<s:property value='#index' />)"><s:property value="#index" /></a>
			      					</s:else>
	      						</s:iterator>
	      					</s:bean>
	      					...
	      				<!-- 显示最后两页 -->
	      					<s:bean name="org.apache.struts2.util.Counter" id="lastCounter">
	      						<s:param name="first" value="pageSize-1" />
	      						<s:param name="last" value="pageSize" />
	      						<s:iterator value="lastCounter" var="index">
	      							<a href="javascript:pageLocate(<s:property value='#index' />)"><s:property value="#index" /></a>
	      						</s:iterator>
	      					</s:bean>
	      				</s:if>
	      				<s:elseif test="pageIndex>=7 && (pageSize-pageIndex)>2">
	      				<!-- 页码不小于7，但又不接近总页数时，分三部分显示：1-3、中间三页、最后一页 -->
	      					<s:bean name="org.apache.struts2.util.Counter" id="frontCounter">
	      						<s:param name="first" value="1" />
	      						<s:param name="last" value="3" />
	      						<s:iterator value="frontCounter" var="index">
	      							<a href="javascript:pageLocate(<s:property value='#index' />)"><s:property value="#index" /></a>
	      						</s:iterator>
	      					</s:bean>
	      					...
	      					<s:bean name="org.apache.struts2.util.Counter" id="middleCounter">
	      						<s:param name="first" value="pageIndex-1" />
	      						<s:param name="last" value="pageIndex+1" />
	      						<s:iterator value="middleCounter" var="index">
	      							<s:if test="#index==pageIndex">
			      						<a href="javascript:void(0)" class="current"><s:property value="#index" /></a>
			      					</s:if>
			      					<s:else>
			      						<a href="javascript:pageLocate(<s:property value='#index' />)"><s:property value="#index" /></a>
			      					</s:else>
	      						</s:iterator>
	      					</s:bean>
	      					...
	      					<a href="javascript:pageLocate(<s:property value='pageSize' />)"><s:property value="pageSize" /></a>
	      				</s:elseif>
	      				<s:else>
	      				<!-- 页码接近总页数，而且页码与总页数的差小于等于2时，分两部分显示：1-3、最后6页 -->
	      					<s:bean name="org.apache.struts2.util.Counter" id="frontCounter">
	      						<s:param name="first" value="1" />
	      						<s:param name="last" value="3" />
	      						<s:iterator value="frontCounter" var="index">
	      							<a href="javascript:pageLocate(<s:property value='#index' />)"><s:property value="#index" /></a>
	      						</s:iterator>
	      					</s:bean>
	      					...
	      					<s:bean name="org.apache.struts2.util.Counter" id="lastCounter">
	      						<s:param name="first" value="pageSize-5" />
	      						<s:param name="last" value="pageSize" />
	      						<s:iterator value="lastCounter" var="index">
	      							<s:if test="#index==pageIndex">
			      						<a href="javascript:void(0)" class="current"><s:property value="#index" /></a>
			      					</s:if>
			      					<s:else>
			      						<a href="javascript:pageLocate(<s:property value='#index' />)"><s:property value="#index" /></a>
			      					</s:else>
	      						</s:iterator>
	      					</s:bean>
	      				</s:else>
	      			</s:else>
	      		<!-- 下一页 -->	
	      			<s:if test="pageSize>pageIndex">
	      				<a href="javascript:pageDown(<s:property value='pageIndex' />)">Next Page</a>
	      			</s:if>
	      			<s:else>
	      				<a href="javascript:void(0)" class="disabled">Next Page</a>
	      			</s:else>
	      		</div>
	    	</div>
	    	<div class="clear"></div>
	  	</div>
	  	<!-- 分页结束 -->
	</div>
  </body>
</html>
